<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<%@include file="/views/common/include/taglib.jsp"%>
	<%@include file="/views/common/include/head.jsp"%>
	<title>D 生活</title>
	<link rel="stylesheet" href="${ctx}/css/page/header2.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/page/reset.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/page/jifen.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/page/shangchennav.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/page/page.css" type="text/css">
	<link rel="stylesheet" href="${ctx}/css/page/footer.css" type="text/css">
	<style type="text/css">
	/* .page ul .active input{
    background-color: #28c7c9;
    color:#fff;
    cursor: pointer;
    }
	.page ul li input:HOVER{
    background-color: #28c7c9;
     cursor: pointer;
	}
	.page ul li:HOVER{
    background-color: #28c7c9;
     cursor: pointer;
	} */
	</style>
</head>
	<script type="text/javascript">
    var ctx = '${ctx}';
    var order = "${order}";
	function changeOrder(od){
		order = od;
		var selectType = $("#selectType").val();
		window.location.href = ctx +"/searchGoodsOrShops?pNo=1"  + "&order=" + order + "&selectType=" +1;
	}
	
	function gotoPage(page){
		var pages = $("#pages").val();
		var order = $("#order").val();
		var selectType = $("#selectType").val();
    	if(page == null || page == 'undefined'){
    		page = this.page;
    	}
   		if(page < 1 ){
       		layer.msg("已到达第一页!", {
   				time : 2000
   			// 2秒关闭（如果不配置，默认是3秒）
   			});
       	} else if(page > pages){
       		layer.msg("已到达最后一页!", {
   				time : 1000
   			// 2秒关闭（如果不配置，默认是3秒）
   			});
       	} else if(order != null && order != 'undefined' && order != ''){
       		window.location.href = ctx +"/searchGoodsOrShops?pNo=" + page + "&order=" + order + "&selectType=" +1;
       		
       	} else {
       		window.location.href = ctx +"/searchGoodsOrShops?pNo=" + page +"&order=" + 1 + "&selectType=" +selectType;
       	}
	}
	
	function searchGoodsOrShops(){
		var selectType = $("#selectType").val();
		var name = $("#name").val();
		window.location.href = ctx +"/searchGoodsOrShops?pNo=1" + "&selectType=" +selectType +"&name=" + name;
	}
	
	function searchGoods(goodCategoryId){
		window.location.href = ctx +"/searchGoodsByCategoryId?pNo=1" + "&goodCategoryId=" + goodCategoryId;
	}
	
	function addToCart(goodsId,shopId,goodsName,logo,price,type,count){
		$.post(ctx +"/shopcart/addToCart",
				{goodsId:goodsId,
			     shopId:shopId,
			    	goodsName:goodsName,
			     logo:logo,
			     price:price,
			     type:type,
			     count:count
				},function(data){
					data = JSON.parse(data);
					if(data.success){
						layer.msg("加入购物车成功",{
							icon: 1,
							time: 2000 //2秒关闭（如果不配置，默认是3秒）
						});
					}
				});
	}
</script>
<body>
    <jsp:include page="/views/common/head_main.jsp" />

	<div class="bg">
	<input type="hidden" id="item" value="${sessionScope.item_mall}"/>
		<div class="contentbox1 contentbox">
			<div class="nav">
				 <ul>
                    <li><a href="${ctx}/main?item=4">商城首页</a></li><span>|</span>
                    <li><a href="${ctx}/mallSeckill">秒杀专区</a></li><span>|</span>
                    <li><a href="${ctx}/main?item=4#article">精品推荐</a></li><span>|</span>
                    <li><a href="${ctx}/main?item=4#hotshop">热门商铺</a></li><span>|</span>
                    <li><a href="${ctx}/mallIntegral">积分专区</a></li>
                </ul>
				<div class="seabox">
					<select class="searchhh" id="selectType">
					<option value="1"<c:if test="${selectType == 1}">selected="selected"</c:if>>商品</option>
					<option value="2"<c:if test="${selectType == 2}">selected="selected"</c:if>>店铺</option>
					</select>
					<input class="search" type="text" id="name"></input><button class="searchbtn" onclick="searchGoodsOrShops()">搜索</button>
				</div>
                <div class="cartbox">
                     <img src="${ctx}/images/mall/cart.png">&nbsp;&nbsp;&nbsp;<a href="${ctx}/shopcart/shopcartList" target="_blank">我的购物车</a>
                </div>
			</div>
		</div>
		<div class="contentbox2 contentbox">
			<div class="content" style="width:1200px;">
				<div class="c-top" style="margin-bottom: 15px;">
					<div class="menu-list">
						<div style="width:100%;background: #57B4C6;height: 50px;text-indent: 20px;line-height: 50px;color: white;font-size: 16px">
						<c:if test="${selectType == 1}">商品<c:if test="${name != null}">&nbsp;&nbsp;/&nbsp;&nbsp;${name }</c:if></c:if>
						<c:if test="${selectType == 2}">店铺<c:if test="${name != null}">&nbsp;&nbsp;/&nbsp;&nbsp;${name }</c:if></c:if>
						</div>
						<div class="blue-stick">
						</div>
					</div>
					<div class="jf-change" style="padding-bottom: 18px;">
						<div>
						<c:forEach items="${goodsCategories}" var="item" varStatus="status">
							    <div class="c-item" style="width:1200px;float: left;margin: 18px 0 0 0;">
										 <div style="font-size: 16px;float:left;margin-left: 20px;width:100px;">${item.name}:</div>
										 <div style="width:800px;margin-left: 120px">
										 <ul>
										 <c:forEach items="${item.secondList}" var="secondList" varStatus="status">
										 <li style="float:left;font-size: 14px;width:70px;cursor: pointer;line-height: 30px;margin-top: -2px;" onclick="searchGoods(${secondList.id})">${secondList.name}</li>
										 </c:forEach>
										 </ul>
										 </div>
								</div>
							</c:forEach>
							</div>
						</div ></div></div>
		</div>
		<div class="contentbox3 contentbox">
			<div class="content" style="width:1200px;">
				<div class="c-top">
				<c:if test="${selectType == 1}">
					<div class="menu-list">
					<input id="order"  type="hidden" value="${order}">
						<ul>
					<c:if test="${order != 1 && order != 2}">
					<li onclick="changeOrder(1)" style="cursor: pointer;margin-left:-1px;">销量</li>
					</c:if>
					<c:if test="${order == 1}">
					<li <c:if test="${order == 1}">class="first"</c:if>  onclick="changeOrder(2)" style="cursor: pointer;margin-left:-1px;">销量&#8593;
					 </li> 
					 </c:if>
					 <c:if test="${order == 2}">
					 <li <c:if test="${order == 2}">class="first"</c:if>  onclick="changeOrder(1)" style="cursor: pointer;margin-left:-1px;">销量&#8595;
					 </li> 
					 </c:if>
					<c:if test="${order != 3 && order != 4}">
							<li onclick="changeOrder(3)" style="cursor: pointer;margin-left:-1px;">价格</li>
					</c:if>
					<c:if test="${order == 3}">
					<li <c:if test="${order == 3}">class="first"</c:if>  onclick="changeOrder(4)" style="cursor: pointer;margin-left:-1px;">价格&#8593; </li> 
					 </c:if>
					 <c:if test="${order == 4}">
					 <li <c:if test="${order == 4}">class="first"</c:if>  onclick="changeOrder(3)" style="cursor: pointer;margin-left:-1px;">价格&#8595;
					 </li> 
					 </c:if>
					<c:if test="${order != 5 && order != 6}">
							<li onclick="changeOrder(5)" style="cursor: pointer;margin-left:-1px;">评论数</li>
					</c:if>
					<c:if test="${order == 5}">
					<li <c:if test="${order == 5}">class="first"</c:if>  onclick="changeOrder(6)" style="cursor: pointer;margin-left:-1px;">评论数&#8593; </li> 
					 </c:if>
					 <c:if test="${order == 6}">
					 <li <c:if test="${order == 6}">class="first"</c:if>  onclick="changeOrder(5)" style="cursor: pointer;margin-left:-1px;">评论数&#8595;
					 </li> 
					 </c:if>
					 <c:if test="${order != 7 && order != 8}">
							<li onclick="changeOrder(7)" style="cursor: pointer;margin-left:-1px;">上架时间</li>
					</c:if>
					<c:if test="${order == 7}">
					<li <c:if test="${order == 7}">class="first"</c:if>  onclick="changeOrder(8)" style="cursor: pointer;margin-left:-1px;">上架时间&#8593; </li> 
					 </c:if>
					 <c:if test="${order == 8}">
					 <li <c:if test="${order == 8}">class="first"</c:if>  onclick="changeOrder(7)" style="cursor: pointer;margin-left:-1px;">上架时间&#8595;
					 </li> 
					 </c:if>
						</ul>
						<div class="blue-stick">
						</div>
					</div>
					</c:if>
					<div class="jf-change">
						<div class="padd1">
						<c:if test="${selectType == 1}">
						<c:forEach items="${goodsInfos.list}" var="item" varStatus="status">
							    <div class="c-item" style="width:210px;">
								    <div class="pic-boxxx">
								    	<a href="${ctx}/GoodsDetail?id=${item.id}&type=1" target="_blank"><img src="${sessionScope.image_logo}${item.logo}" style="width:130%;"></a>
								    </div>
								    <div style="width:200px;">
										 <p><a >￥${item.price}</a></p>
								    	 <p style="width:162.5px;">${item.name}</p>
                                         <div style="border: 1px solid #ddd;text-align: center;width:60px;float:left">
                                        <a href="${ctx}/shopIndex?pNo=1&shopId=${item.shopId}&shopName=${name}" target="_blank">
                                         <span>${item.shopName}</span>
                                         </a>
                                         </div>
<!--                                          <div style="border: 1px solid #ddd;text-align: center;width:90px;float:left;margin-left:10px;"> -->
<%-- 										<span><img src="${ctx}/images/mall/shop/cart.png"></span> --%>
<%-- 										<span onclick="addToCart('${item.id}','${item.shopId}','${item.name}','${item.logo}','${item.price}','${item.type}','1')" style="cursor: pointer;">加入购物车</span> --%>
<!--                                          </div> -->
									</div>
								</div>
							</c:forEach>
							</c:if>
							<c:if test="${selectType == 2}">
						<c:forEach items="${shopInfos.list}" var="item" varStatus="status">
							    <div class="c-item" style="width:210px;">
							    <div class="pic-boxxx">
							    	<a href="${ctx}/shopIndex?pNo=1&shopId=${item.id}&shopName=${name}" target="_blank">
							    		<c:if test="${ not empty item.logo}">
											<img class="first big" width="" height="" src="${sessionScope.image_logo}${item.logo}"/>
										</c:if>
										<c:if test="${ empty item.logo}">
											<img class="first big" width="" height="" src="${ctx}/images/mall/default_shop.jpg"/>
										</c:if>
							    	</a>
							    </div>
							    <div style="width:200px;">
							    	<p>${item.name}</p>
							    	 <div><a href="${ctx}/shopIndex?pNo=1&shopId=${item.id}&shopName=${name}" target="_blank">
							    	 <button style="cursor: pointer;">进店逛逛</button></a></div>
								</div>
							</div>
							</c:forEach>
							</c:if>
							</div>
						</div >
					<c:if test="${selectType == 1}">
							<div class="page">
									<input id="pages" type="hidden" value="${goodsInfos.pages}">
									<ul>
										<li><a class="last-page page-change " onclick="gotoPage(${currentPage-1 });">&lt;上一页</a></li>
										<c:if test="${goodsInfos.firstPage > 1}">
											<li onclick="gotoPage(1);"
												class="page-num"><a>1</a></li>
											<c:if test="${goodsInfos.firstPage > 2}">
				                       		...
				                       		</c:if>
										</c:if>
										<c:forEach items="${goodsInfos.navigatepageNums }" var="page">
											<li onclick="gotoPage(${page });"
												class="<c:if test="${currentPage == page }">current</c:if>"
												class="page-num"><a>${page}</a></li>
										</c:forEach>
										<c:if test="${goodsInfos.lastPage < goodsInfos.pages}">
											<c:if test="${goodsInfos.firstPage < goodsInfos.pages - 1}">
				                       		...
				                       		</c:if>
											<li onclick="gotoPage(${goodsInfos.pages});"
												class="page-num"><a>${goodsInfos.pages}</a>
											</li>
										</c:if>
										<li><a class="next-page page-change" onclick="gotoPage(${currentPage+1 });">下一页&gt;</a></li>
									</ul>
								</div>
					
					
					
					
								<%-- <ul>
								<c:if test="${goodsInfos.hasPreviousPage }">
									<li onclick="gotoPage(${currentPage-1 });" ><a class="last-page page-change " href="javascript:void(0)">&lt;上一页</a></li>
								</c:if>
								 <c:if test="${goodsInfos.firstPage > 1}">
									<li onclick="gotoPage(1);" > <input class="page-num"  value="1"></input></li>
									<c:if test="${goodsInfos.firstPage > 2}">
				                        		...
				                    </c:if>
				                 </c:if>
				                 <c:forEach items="${goodsInfos.navigatepageNums }" var="page">
									<li onclick="gotoPage(${page });" class="<c:if test="${currentPage == page }">active</c:if>" >
									<input class="page-num" value="${page}"></input></li>
								 </c:forEach>
								 <c:if test="${goodsInfos.lastPage < goodsInfos.pages}">
				                        	<c:if test="${goodsInfos.firstPage < goodsInfos.pages - 1}">
				                        		...
				                            </c:if>
									<li onclick="gotoPage(${goodsInfos.pages});" >
									<input class="page-num" value="${goodsInfos.pages}"></input></li>
									</c:if>
				                <c:if test="${goodsInfos.hasNextPage }">
									<li onclick="gotoPage(${currentPage+1});"><a class="next-page page-change" href="javascript:void(0)">下一页&gt;</a></li>
								</c:if>
								</ul> --%>
					</c:if>	
					<c:if test="${selectType == 2}">
							<div class="page">
									<input id="pages" type="hidden" value="${shopInfos.pages}">
									<ul>
										<li><a class="last-page page-change " onclick="gotoPage(${currentPage-1 });">&lt;上一页</a></li>
										<c:if test="${shopInfos.firstPage > 1}">
											<li onclick="gotoPage(1);"
												class="page-num"><a>1</a></li>
											<c:if test="${shopInfos.firstPage > 2}">
				                       		...
				                       		</c:if>
										</c:if>
										<c:forEach items="${shopInfos.navigatepageNums }" var="page">
											<li onclick="gotoPage(${page });"
												class="<c:if test="${currentPage == page }">current</c:if>"
												class="page-num"><a>${page}</a></li>
										</c:forEach>
										<c:if test="${shopInfos.lastPage < shopInfos.pages}">
											<c:if test="${shopInfos.firstPage < shopInfos.pages - 1}">
				                       		...
				                       		</c:if>
											<li onclick="gotoPage(${shopInfos.pages});"
												class="page-num"><a>${shopInfos.pages}</a>
											</li>
										</c:if>
										<li><a class="next-page page-change" onclick="gotoPage(${currentPage+1 });">下一页&gt;</a></li>
									</ul>
								</div>
					
					
					
								<%-- <ul>
								<c:if test="${shopInfos.hasPreviousPage }">
									<li onclick="gotoPage(${currentPage-1 });" ><a class="last-page page-change " href="javascript:void(0)">&lt;上一页</a></li>
								</c:if>
								 <c:if test="${shopInfos.firstPage > 1}">
									<li onclick="gotoPage(1);" > <input class="page-num"  value="1"></input></li>
									<c:if test="${shopInfos.firstPage > 2}">
				                        		...
				                    </c:if>
				                 </c:if>
				                 <c:forEach items="${shopInfos.navigatepageNums }" var="page">
									<li onclick="gotoPage(${page });" class="<c:if test="${currentPage == page }">active</c:if>" >
									<input class="page-num" value="${page}"></input></li>
								 </c:forEach>
								 <c:if test="${shopInfos.lastPage < shopInfos.pages}">
				                        	<c:if test="${shopInfos.firstPage < shopInfos.pages - 1}">
				                        		...
				                            </c:if>
									<li onclick="gotoPage(${shopInfos.pages});" >
									<input class="page-num" value="${shopInfos.pages}"></input></li>
									</c:if>
				                <c:if test="${shopInfos.hasNextPage }">
									<li onclick="gotoPage(${currentPage+1});"><a class="next-page page-change" href="javascript:void(0)">下一页&gt;</a></li>
								</c:if>
								</ul> --%>
					</c:if>			
					</div>
					</div>
				</div>
			</div>
	<jsp:include page="/views/common/footer.jsp" />
	</body>
	</html>